HA$PBExportHeader$u_cst_manto_dw.sru
forward
global type u_cst_manto_dw from u_cst_tabpage
end type
type dw_2 from datawindow within u_cst_manto_dw
end type
type dw_1 from datawindow within u_cst_manto_dw
end type
end forward

global type u_cst_manto_dw from u_cst_tabpage
integer width = 3081
integer height = 2140
event ue_mostrar ( powerobject ap_object,  boolean ab_tab )
event type integer ue_grabar ( )
event type long ue_getdwmodified ( )
dw_2 dw_2
dw_1 dw_1
end type
global u_cst_manto_dw u_cst_manto_dw

type variables
s_parm istr_parm
boolean dw_has_focus
string is_error  ,is_button,is_tabla ,is_idcodigo,is_entidad

long il_id 
integer ii_currentrow
datastore ids_datastore
Window iw_parent
u_cst_powerdock uo_powerdock
userobject iuo_tab

//u_cst_tabcontrol iuo_parent 

u_cst_grillamain_fichas iuo_grillamain
u_cst_tabmantomain_fichas iuo_tabmantomain
end variables

forward prototypes
public function integer of_getwindow ()
end prototypes

event ue_mostrar(powerobject ap_object, boolean ab_tab);string ls_dw,ls_button,ls_entidad
long ll_codigo,ll_Rows
//f_msj('MOSTRAR_PRUEBA',4) 
//RETURN
istr_parm        = ap_object

ids_datastore   = istr_parm.ads_menu //aqui recupera el datastore
uo_powerdock = istr_parm.auo_powerdock 
ls_button         = istr_parm.as_button
//ls_dw              = ids_datastore.object.tDw1[1]
ls_dw =             istr_parm.as_string1
is_tabla           = ids_datastore.object.tTabla[1]
iuo_tab            = istr_parm.auo_userobject
is_idcodigo			=  istr_parm.as_parm[1] //id tabla
is_button = ls_button
if  ab_tab  then
	dw_1.dataobject=ls_dw
	dw_2.dataobject=ls_dw
	dw_1.settransobject(sqlca)
end if
choose case upper(is_button)
	case 'NUEVO'
		dw_1.accepttext( ) //= -1  then return
		ll_Rows = dw_1.ModifiedCount()
		IF ll_Rows > 0  then
			if f_msj('$$HEX1$$bf00$$ENDHEX$$Desea guardar los cambios que hizo al usuario?',2) = 2 then return
		end if
		//	uo_powerdock.of_setdocumenttext( iuo_tab ,'Nuevo / '+ is_tabla)
			dw_1.reset()
			dw_1.insertrow( 0)
			dw_1.enabled= true
//		     uo_toolbarstrip.of_setenabled( 'Grabar', true)		
	 		//uo_toolbarstrip.of_setenabled( 'Cancelar', true)
	CASE 'EDITAR'
		dw_1.accepttext( ) //= -1  then return
//		ll_Rows = dw_1.ModifiedCount()
//		IF ll_Rows > 0  then
//			if f_msj('$$HEX1$$bf00$$ENDHEX$$Desa guardar los cambios que hizo al usuario?',2) = 2 then return
//		end if
//
	//	uo_powerdock.of_setdocumenttext( iuo_tab ,'Editar / '+ is_tabla)
		dw_1.retrieve(is_idcodigo) ;				commit;
		dw_1.enabled= true
//		uo_toolbarstrip.of_setenabled( 'Grabar', true)		
//		uo_toolbarstrip.of_setenabled( 'Cancelar', TRUE)
	CASE 'CONSULTAR'
		dw_1.accepttext( )// = -1  then return
		ll_Rows = dw_1.ModifiedCount()
		IF ll_Rows > 0  then
			if f_msj('$$HEX1$$bf00$$ENDHEX$$Desa guardar los cambios que hizo al usuario?',2) = 2 then return
		end if
		//uo_powerdock.of_setdocumenttext( iuo_tab ,'Consultar / '+ is_tabla)
		dw_1.retrieve(is_idcodigo) ; 	commit;
		dw_1.enabled= false
//		uo_toolbarstrip.of_setenabled( 'Grabar', false)
//		uo_toolbarstrip.of_setenabled( 'Cancelar', false)
END CHOOSE

end event

event type integer ue_grabar();integer li_return=1
if dw_1.accepttext( ) = -1 Then Return  0
If f_findrequired(dw_1) = -1 Then Return  0
if dw_1.update(true,false) = 1 then 
	dw_1.resetupdate()
	RETURN 1
else
	return 0
end if


end event

event type long ue_getdwmodified();dw_1.accepttext( ) //= -1  then return
return dw_1.ModifiedCount()
end event

public function integer of_getwindow (); PowerObject	lpo_parent
Window lw_window

// loop thru parents until a window is found
lpo_parent = GetParent()
Do While lpo_parent.TypeOf() <> Window! and IsValid(lpo_parent)
	lpo_parent = lpo_parent.GetParent()
Loop

// set return to the window or null if not found
If IsValid (lpo_parent) Then
	lw_window = lpo_parent
Else
	SetNull(lw_window)
End If

iw_parent = lw_window

RETURN 1
end function

on u_cst_manto_dw.create
int iCurrent
call super::create
this.dw_2=create dw_2
this.dw_1=create dw_1
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.dw_2
this.Control[iCurrent+2]=this.dw_1
end on

on u_cst_manto_dw.destroy
call super::destroy
destroy(this.dw_2)
destroy(this.dw_1)
end on

event constructor;call super::constructor;//string ls_dw3,ls_dw2,ls_opc,ls_dw,ls_user
//long ll_codigo
//
//of_getwindow()
//istr_parm        = message.powerobjectparm
//
////ids_datastore   = istr_parm.ads_menuficha //aqui recupera el datastore
////uo_powerdock = istr_parm.auo_powerdock 
////ls_button         = istr_parm.as_button
//ls_dw               = istr_parm.as_string1
//
////
////ls_dw                 = ids_datastore.object.tDw1[1]
////is_tabla           = ids_datastore.object.tTabla[1]
////iuo_tab            = istr_parm.auo_userobject
//
////dw_1.dataobject=ls_dw
////dw_1.settransobject(sqlca)
////dw_1.insertrow( 0)
//EVENT ue_mostrar (istr_parm,true)
//

string ls_dw3,ls_dw2,ls_opc,ls_dw,ls_user
long ll_codigo

istr_parm = message.powerobjectparm 

//uo_toolbarstrip.visible = false
dw_1.visible = false
of_getwindow()

ids_datastore   = istr_parm.ads_menu //aqui recupera el datastore
uo_powerdock = istr_parm.auo_powerdock 
is_button         = istr_parm.as_button
ls_dw              = ids_datastore.object.tDw1[1]
is_tabla           = ids_datastore.object.tTabla[1]
is_entidad = ids_datastore.object.tEntidad[1]
iuo_tab            = istr_parm.auo_userobject 
iuo_grillamain  = istr_parm.auo_grillamain_fichas
iuo_tabmantomain = istr_parm.auo_tabmantomain_fichas
is_idcodigo			=  istr_parm.as_parm[1] //id tabla
if ls_dw = '' or isnull(ls_dw) then return

dw_1.dataobject=ls_dw
dw_2.dataobject=ls_dw
dw_1.settransobject(sqlca)
dw_2.settransobject(sqlca)
dw_1.reset()
//st_titulo.text = ids_datastore.object.tTitulo[1]
//st_det1.text = ids_datastore.object.tObse1[1]
//st_det2.text = ids_datastore.object.tObse2[1]
//il_error =0
//uo_1.of_BackColor2(of_GetColor("BACKGROUND2"))
//uo_1.of_BackColor2(RGB(129,169,226))
end event

event resize;call super::resize;//uo_toolbarstrip.Width =(this.width - 12) 
DW_1.Resize(Width, Height  )
DW_2.Resize(Width, Height  )
end event

event ue_postconstructor;call super::ue_postconstructor;
//choose case upper(is_button)
//	case 'NUEVO'
//		  uo_toolbarstrip.of_setenabled( 'Grabar', true)	
//		  uo_toolbarstrip.of_setenabled( 'Cancelar', true)
//		  dw_1.setcolumn( 4)
//		  dw_1.setfocus( )
//		 
//	case 'EDITAR'
//		 uo_toolbarstrip.of_setenabled( 'Grabar', true)	
//		 uo_toolbarstrip.of_setenabled( 'Cancelar', true)
//		 dw_1.setcolumn( 4)
//		 dw_1.setfocus( )
// case 'CONSULTAR'
//		 uo_toolbarstrip.of_setenabled( 'Grabar', FALSE)		
//		uo_toolbarstrip.of_setenabled( 'Cancelar', false)
//End choose 
end event

type dw_2 from datawindow within u_cst_manto_dw
integer width = 3054
integer height = 2136
integer taborder = 20
string title = "none"
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

type dw_1 from datawindow within u_cst_manto_dw
event ue_enter pbm_dwnprocessenter
event ue_setcolor ( long al_color )
integer width = 3063
integer height = 2132
integer taborder = 10
string title = "none"
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

event ue_enter;Send( Handle( this ), 256, 9, Long( 0, 0 ) ) // Send message for processing TAB key 
return 1 
end event

event ue_setcolor(long al_color);integer li_columna,li_index
string  ls_columna,ls_Required,ls_style

li_columna = integer(this.Object.DataWindow.Column.Count)

for li_index=1 to li_columna
	
	  ls_Columna="#" + string(li_index) + ".name"
	 //Nombre de la Columna
	 Ls_Columna=This.Describe(Ls_Columna)
	 //Estilo de Edicion
	 ls_Style=Ls_Columna + ".edit.style"
	 Ls_Style=lower(This.Describe(Ls_Style))
	 
	 CHOOSE CASE Ls_Style
		CASE 'dddw'
			Ls_Required=lower(This.Describe(Ls_Columna + ".dddw.Required"))
		CASE 'ddlb'
			Ls_Required=lower(This.Describe(Ls_Columna + ".ddlb.Required")			)
		CASE 'edit'
			Ls_Required=lower(This.Describe(Ls_Columna + ".edit.Required"))
		CASE 'editmask'
			Ls_Required=lower(This.Describe(Ls_Columna + ".editmask.Required"))
		CASE ELSE
			Continue
	 END CHOOSE
	 
	 If Ls_Required='yes' Then
		Ls_Columna=Ls_Columna + '.Background.Color=' + string(al_color)
		This.Modify(Ls_Columna)
	 End If
	 
next
end event

event itemchanged;this.accepttext( )
Choose Case dwo.name

	Case 'idmenu'
		If Trim(data) = '' Or IsNull(data) Then
			is_error = 'Error, Digite un C$$HEX1$$f300$$ENDHEX$$digo Valido'
			Return 1
		End If
End choose 
end event

event itemerror;Choose Case dwo.name
	case 'idmenu'
		MessageBox('Advertencia','ingrese el menu',stopsign!)
		
	Case 'idprefil'
		MessageBox('Advertencia','ingrese el perfil',stopsign!)
//	      MessageBox('Advertencia',is_error,Stopsign!)
	Case 'cc_locac','cc_almac','ci_tipart'
//		MessageBox('Advertencia',is_error,stopsign!)
	Case 'cc_docum','cn_docum'
//		MessageBox('Advertencia',is_error,stopsign!)
End Choose

Return 1
end event

event rowfocuschanged;//dwitemstatus ldwitemstatus
//
//if currentrow < 1 then return
//
////if ib_lista or ib_tablist then return
//
//ldwitemstatus=this.getitemstatus(this.rowcount(),0,primary!)
//
//if ldwitemstatus=new! or ldwitemstatus=newmodified! then
//	this.scrolltorow(this.rowcount())
//	return
//end if
//
//if ii_currentrow=0 then ii_currentrow=currentrow
//this.selectrow(ii_currentrow,FALSE)
//this.selectrow(currentrow,TRUE)
//this.setrow(currentrow)
//ii_currentrow=currentrow
//
end event

event constructor;event ue_setcolor(rgb(27,208,228))
end event

